package ezai

import (
	"gitee.com/hongzhaomin/gspring"
	"gitee.com/hongzhaomin/gspring/annotation"
	"gitee.com/hongzhaomin/hzm-common-go/easyconfig"
)

func init() {
	gspring.Register(ConfigBean{}, ConfigurationBean{})
}

type ConfigBean struct {
	annotation.Component
	easyconfig.ConfigurationProperties `prefix:"gspring.ai"`

	Url    string
	ApiKey string
	Model  string
	Stream bool
}

type ConfigurationBean struct {
	annotation.Configuration
	AiToolsList []AiTools `@Resource:""`

	ezAi         annotation.Bean
	cacheSession annotation.Bean
	toolParser   annotation.Bean
}

func (my ConfigurationBean) EzAi() ChatClient {
	return &DefaultChatClient{}
}

func (my ConfigurationBean) CacheSession() *LocalCacheChatSession {
	return NewCacheChatSession()
}

func (my ConfigurationBean) ToolParser() *ToolParser {
	parser := NewToolParser()
	parser.ParseTools(my.AiToolsList...)
	return parser
}
